﻿using System;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

namespace Mvc.Validation.Validators
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
    public sealed class StringLengthValidatorAttribute : BaseValueValidatorAttribute
    {
        public int MaxLength { get; set; }
        protected override Validator DoCreateValidator(Type targetType)
        {
            return new StringLengthValidator(MessageTemplate);
        }

        public override string FormattedMessageTemplate
        {
            get { return "Element length must be less"; }
        }
    }
}